<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pages extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	
    function __construct()
    {
        parent::__construct();
    	$this->load->library('session');
    	//$this->load->database();
    	$this->load->model("centermod");
    	$this->load->helper('url');
    	$this->load->helper('language');
    	$this->load->helper('imagemerge');
    	$this->load->library('email');
    	
    	
	}
	function toolsgetidbystr($str)
	{
		$arr_str=explode("-",$str);
		if(count($arr_str)==2)
		{
			return($arr_str[0]);
		}else
		{
			return "";
		}
	}
			
    
	public function index()
		{
			
			$this->lang->load('pages');
			$lang=$this->config->item('language');
			$data["lang"]=$lang;
			$data["listfeatures"]=$this->centermod->listfeatures();
			
			//list group
			$data["lg"]=$this->centermod->listgroup();
			
			$data["page"]="home";
			$this->load->view("index",$data);
		}
	
	public function tours($groupstr="all")
	{
		if($groupstr!="all")
		{ 
			$group=$this->toolsgetidbystr($groupstr);
			$listgroup=$this->centermod-> getgroupbyid(intval($group));
		
		}else 
		{
			$listgroup=$this->centermod->listgroup();
		}
		
		
		$this->lang->load('pages');
		$lang=$this->config->item('language');
		
		
		$data["array_grouptours"]=array();
		$data["lang"]=$lang;
		$data["page"]="tours";
		//list group
			$data["lg"]=$this->centermod->listgroup();
			
		foreach($listgroup as $lg)
		{
			
			$listours=$this->centermod->gettoursbyidgroup($lg["idweb_group"]);
			$array_tour=array("name"=>$lg,"tours"=>$listours);
			$data["array_grouptours"][]=$array_tour;
			
		}
		
		$this->load->view("listtours",$data);
		
	}

	public  function detailtour($stridtours)
	{
		if($stridtours!="")
		{
			$idtours=$this->toolsgetidbystr($stridtours);
			
			
		$this->lang->load('pages');
		$data["lang"]=$this->config->item('language');	
		$data["detailtour"]=$this->centermod->getwebtourswithpricebyid(intval($idtours));
		$data["page"]="tours";
		//list group
			$data["lg"]=$this->centermod->listgroup();
		$this->load->view("detailtour",$data);
		
		}	
	}
	
	public  function aboutus()
	{
		$this->lang->load('pages');
		$data["lang"]=$this->config->item('language');
		$data["page"]="aboutus";
		$data["lg"]=$this->centermod->listgroup();
		$this->load->view("aboutus",$data);	
		
	}
	
		public  function contactus()
	{
		$this->lang->load('pages');
		$data["lang"]=$this->config->item('language');
		$data["page"]="contactus";
		$data["lg"]=$this->centermod->listgroup();
		$this->load->view("contactus",$data);	
		
	}
	
	
	
}
?>
